#ifndef EVENT_HANDLE_H_
#define EVENT_HANDLE_H_

#include "base/base.h"

namespace rpc {
class Buffer;
class Connection;
class Protocol;
class Processor;

class RpcEventHandle {
  public:
    virtual ~RpcEventHandle() {
    }


    void SetProcessor(Processor* processor) {
      CHECK_NOTNULL(processor);
      processor_.reset(processor);
    }

    virtual void HandleRead(Connection* conn, Buffer* buf);
    virtual void HandleWrite(Connection* conn);
    virtual void HandleClose(Connection* conn);

  protected:
    RpcEventHandle(Protocol* protocol = NULL, Processor* processor = NULL)
        : protocol_(protocol), processor_(processor) {
    }

    scoped_ptr<Protocol> protocol_;
    scoped_ptr<Processor> processor_;

  private:
    DISALLOW_COPY_AND_ASSIGN(RpcEventHandle);
};

}

#endif
